# -*- coding:utf-8 -*-
"""
@Author    :Ven
@FileName  :_uiautomator2.py
@Time      :2021/12/30 15:33
@文档说明   :
"""
from functools import wraps
#说明:使用库uiautomator2会安装com.github.uiautomator和com.github.uiautomator.test,在使用appium时需要删除
#adb  shell  pm  list packages 列出第三方的安装包
import uiautomator2 as u2


def singleton(cls):
    """单例类装饰器"""
    instances = {}
    @wraps(cls)
    def wrapper(*args, **kwargs):
        if cls not in instances:
            instances[cls] = cls(*args, **kwargs)
        return instances[cls]

    return wrapper

@singleton
class Driver():
    def __new__(cls, *args, **kwargs):
        cls.driver = u2.connect()
        cls.driver.app_start('com.sykean.biometrics')
        print(cls.driver.current_app)
        cls.driver(resourceId="com.sykean.biometrics:id/image_logo").click()
        #cls.driver(text="2").click()
        cls.driver.double_click()
        return cls.driver

if __name__ == '__main__':
    d = Driver()